package com.qf.mq.listener;

import com.qf.events.BlackChangeEvents;
import com.qianfeng.smsplatform.common.constants.RabbitMqConsants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/*
 * @Data: 2021/7/15 21:32
 * */
@Component
public class BlackNumChangeListener {
    private ApplicationContext context;
    @Autowired
    public void setContext(ApplicationContext context) {
        this.context = context;
    }

    //    接收来自黑名单交换机的消息
    @StreamListener(RabbitMqConsants.TOPIC_BLACKNUM_UPDATE)
    public void msg(String msg){

        System.out.println("收到的黑名单消息是"+msg);
        context.publishEvent(new BlackChangeEvents());
    }

}
